package cn.yoyo.service;

import cn.yoyo.dao.BlogDao;
import cn.yoyo.dao.ContentDao;
import cn.yoyo.entity.Blog;
import cn.yoyo.entity.Content;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class ContentServiceImpl implements ContentService{
    @Autowired
    ContentDao contentDao;
    @Autowired
    BlogDao blogDao;

    @Override
    public Content findById(String blogId,String contentId) {
        Blog blog = blogDao.findById(blogId);
        Map<String,Object> map = new HashMap<>();
        map.put("blogId",blogId);
        map.put("pageviews",blog.getPageviews()+1);
        blogDao.updateSum(map);
        return contentDao.findById(contentId);
    }
}

